Safe Area
Safe area modifiers in Scripting allow you to adjust layout behavior relative to the system-defined safe areas, such as the areas around notches, toolbars, or the on-screen keyboard.
safeAreaPadding
Adds custom padding inside the safe area of a view. This modifier adjusts the visible content region by extending or inseting from the edges defined by the system’s safe area (e.g., accounting for the notch, home indicator, or rounded corners).
Type
Description
This modifier gives fine-grained control over how much padding should be added inside the safe area for specific edges or directions. You can either apply:
- A default system padding by passing
true - A uniform padding value by passing a
number - Directional padding for each edge using a detailed configuration object
This modifier is particularly useful when you want the view to respect or override the system safe area while maintaining proper layout spacing.
Usage Options
true: Applies default system padding on all safe area edgesnumber: Applies the specified number of points as uniform padding on all edgesobject: Specifies padding per edge or direction
Object Properties
horizontal: Padding for bothleadingandtrailingedgesvertical: Padding for bothtopandbottomedgesleading,trailing,top,bottom: Individual edge-specific padding- Values can be a
numberortrueto apply system default padding for that edge
Example: Default Padding
Applies system default padding on all safe area edges.
Example: Custom Padding
Adds 20 points of padding at the top, system default padding at the bottom, and 12 points on both horizontal edges.
safeAreaInset
Inserts a custom view into the safe area edge of another view.
Type
Description
- Adds content (such as toolbars, controls, or info bars) to the specified safe area edge:
top,bottom,leading, ortrailing. - You can control alignment (horizontal or vertical) and spacing between the original view and the inserted content.
- Typically used in scrollable or full-screen layouts where you want to place persistent UI elements without obstructing core content.
Example
Alignment Options
- Horizontal (for
topandbottom):"leading","center","trailing" - Vertical (for
leadingandtrailing):"top","center","bottom"
Notes
spacingis optional. If omitted, a default system spacing will be applied.- The
spacingtypo in theleading/trailingdefinition should be interpreted asspacing.
ignoresSafeArea
Expands a view’s content to extend into one or more safe area regions.
Type
Description
- Allows a view to "ignore" the system-defined safe areas and occupy the full screen or extend under system UI.
- Useful for immersive layouts like full-screen images, maps, or background layers.
Boolean Usage
This will ignore all safe area regions on all edges.
